import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { VantResolver } from '@vant/auto-import-resolver';
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    legacy(),
    AutoImport({
      resolvers: [ElementPlusResolver(),VantResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver(), VantResolver()],
    }),
  ],
  server: {
    port: 8080,
    host: '0.0.0.0',
    open: true,
    https: false,
    proxy: {
      // '/nav_front_web': {
      //   target: 'http://test.yuanxinbaoxian.com/',
      //   changeOrigin: true,
      //   rewrite: (path) => path.replace(/^\/nav_front_web/, '')
      // },
    }
  },
  base: './',
  outDir: 'dist',
  resolve: {
    alias: {
      '@': resolve(__dirname, '.', 'src')
    },
    extensions: ['.js', '.ts', '.jsx', '.json', '.vue', '.mjs']
  },
  css: {
    preprocessorOptions: {
      scss: {
        silenceDeprecations: ['legacy-js-api'],
        api: 'modern-compiler' // or "modern"
      }
    }
  }
})
